package ModelLayer;
import java.util.ArrayList;

/**
 * Write a description of class AdressBook here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class AddressBook
{
   private ArrayList<Person> contacts;

    /**
     * Constructor
     * Initializa the instance fields
     */
    public AddressBook()
    {
        contacts = new ArrayList<Person>();
    }

    /**
     * The method that add a new student  
     */
    public void addContact(Person newContact)
    {
        
        contacts.add(newContact);
    }
    public Person findContact(int search)
    {
        boolean found = false;
        int x = 0;
        while(x < contacts.size() && !found)
        {
            Person s = contacts.get(x);
            if(s.getID() == search)
            {
                found = true;
            }
            else{
                x++;
            }
        }
        if(found){
            return contacts.get(x);
        }
        else{
            return null;
        }
    }
    public void updateContact(int search)
    {
        boolean found = false;
        int x = 0;
        while(x < contacts.size() && !found)
        {
            Person s = contacts.get(x);
            if(s.getID() == search)
            {
                found = true;
            }
            else{
                x++;
            }
        }
        if(found){
            contacts.setPhone();
        }
        else{
            return null;
        }
        
    }

}
